<?php
class OrganController extends CommonController
{
	public function index()
	{
		$organModelCls = new OrganModel($this->uid);
		$organ = $organModelCls->getAll();
		
		$this->view->assign('title', '机构信息');
		$this->view->assign('Organ', $organ);
		$this->view->setPlace('content', 'place/organ');
		$this->view->display();
	}
	
	/**
	 * 添加机构信息
	 */
	public function add()
	{
		$do = Functions::gpc('do', 'p');
		if($do == 'save')
		{
			$data['OrganName'] = Functions::sqlgpc('OrganName', 'p');
			$data['OrganType'] = Functions::sqlgpc('OrganType', 'p');
			$data['CreateDate'] = time();
			$data['Status'] = Functions::sqlgpc('Status', 'p');
			$data['Remark'] = Functions::sqlgpc('Remark', 'p');
			$organModelCls = new OrganModel($this->uid);
			$organModelCls->add($data);
		}
		
	    if($this->isAjax)
		{
		    $this->view->setUseLayout(false);
		}
		else
		{
		    $this->view->setPlace('content', 'page/organ/add');
		}
		
		$this->view->display();
	}
	
	public function __destruct()
	{
		//echo 'index controller destruct!<br />';
	}
}